
globalThis.decryptAES = function (ciphertext) {
    const keyBytes = CryptoJS.enc.Utf8.parse("ca94b06ca3c7d80s");
    const ivBytes = CryptoJS.enc.Utf8.parse("ca94b06ca3c7d80s");
    try {
        const decrypted = CryptoJS.AES.decrypt(
            ciphertext,
            keyBytes,
            {
                iv: ivBytes,
                mode: CryptoJS.mode.CBC,
                padding: CryptoJS.pad.Pkcs7
            }
        );
        return decrypted.toString(CryptoJS.enc.Utf8) || '';
    } catch (error) {
        console.error('AES 解密失败:', error.message);
        return '';
    }
}


var rule = {
	title:'看视界',
	host:'http://59.153.167.183:520',
	homeUrl:'/attapp.php/v1/getRankingLists?id=1&all=1',
	url:'/attapp.php/v1/typeFilterVodList?page=fypage&limit=20&type_id=fyclass',
	detailUrl:'/attapp.php/v1/video_detail?vod_id=fyid',
	searchUrl:'/attapp.php/v1/searchList?keywords=**&page=fypage',
  class_name:'电影&电视剧&综艺&动漫&短剧&直播',
  class_url: '1&2&3&4&38&39',
  searchable: 2,//是否启用全局搜索,
  quickSearch: 0,//是否启用快速搜索,
  filterable: 0,//是否启用分类筛选,
  timeout: 5000,
  推荐: $js.toString(() => {
  	let d = [];
    let str=fetch(input);
    let list=JSON.parse(decryptAES(JSON.parse(str).data)).list;
    list.forEach(it => {
      d.push({
        url:it.vod_id,
        title: it.vod_name,
        desc: it.vod_remarks,
        img: it.vod_pic
      })
    });
    setResult(d);
  }),
  一级: $js.toString(() => {
  	let d = [];
    let str=fetch(input);
    let list=JSON.parse(decryptAES(JSON.parse(str).data)).recommend_list;
    list.forEach(it => {
      d.push({
        url:it.vod_id,
        title: it.vod_name,
        desc: it.vod_remarks,
        img: it.vod_pic
      })
    });
    setResult(d);
  }),
  二级:$js.toString(() => {
    let str=fetch(input);
    let jsony=JSON.parse(decryptAES(JSON.parse(str).data)).vod_info;
    let ktabs = jsony.vod_url_with_player.map((it) => { return '' + it.code });
    let kurls = jsony.vod_url_with_player.map((it) => { return '' + it.url });
    VOD = {
      vod_name:jsony.vod_name,
      type_name: jsony.vod_class,
      vod_pic: jsony.vod_pic,
      vod_remarks: jsony.vod_remarks,
      vod_year: jsony.vod_year,
      vod_area:jsony.vod_area,
      vod_lang:jsony.vod_lang,
      vod_actor:jsony.vod_actor,
      vod_content:jsony.vod_content+input,
      vod_play_from: ktabs.join('$$$'),
      vod_play_url: kurls.join('$$$')
    };
  }),
  play_parse: true,
	lazy: $js.toString(() => {
		if (/\.m3u8/.test(input)) {
			input = { jx: 0, parse: 0, url: input }
		} else if (/NBY/.test(input)) {
			input = `http://43.248.100.143:6888/api/?key=o7bk2nOVbDHZZLrNb2&url=${input}`;
			input = JSON.parse(fetch(input)).url;
			input = { jx: 0, parse: 0, url: input }
		} else if (/YYNB/.test(input)) {
			input = `http://59.153.167.183:177/yy.php?url=${input}`;
			input = JSON.parse(fetch(input)).url;
			input = { jx: 0, parse: 0, url: input }
		} else if (/Ace/.test(input)) {
			input = `http://59.153.167.183:177/ace.php?url=${input}`;
			input = JSON.parse(fetch(input)).url;
			input = { jx: 0, parse: 0, url: input}
		} else if (/MLHG/.test(input)) {
			input = `http://103.255.69.29:1115/jiexi/hongguo/jiexi/jiexi.php?url=${input}`;
			input = JSON.parse(fetch(input)).url;
			input = { jx: 0, parse: 0, url: input}
		} else if (/qq.com/.test(input)) {
			input = `http://59.153.167.183:177/gj.php?url=${input}`;
			input = JSON.parse(fetch(input)).url;
			input = { jx: 0, parse: 0, url: input }
		} else if (/youku.com/.test(input)) {
			input = `http://59.153.167.183:177/gj.php?url=${input}`;
			input = JSON.parse(fetch(input)).url;
			input = { jx: 0, parse: 0, url: input }
			} else if (/iqiyi.com/.test(input)) {
			input = `http://59.153.167.183:177/gj.php?url=${input}`;
			input = JSON.parse(fetch(input)).url;
			input = { jx: 0, parse: 0, url: input }
			} else if (/mgtv.com/.test(input)) {
			input = `http://59.153.167.183:177/gj.php?url=${input}`;
			input = JSON.parse(fetch(input)).url;
			input = { jx: 0, parse: 0, url: input }
		} else {
			input = { jx: 0, parse: 1, url: input }
		}
	}),
  搜索: $js.toString(() => {
  	let d = [];
    let str=fetch(input);
    let list=JSON.parse(decryptAES(JSON.parse(str).data)).search_list;
    list.forEach(it => {
      d.push({
        url:it.vod_id,
        title: it.vod_name,
        desc: it.vod_remarks,
        img: it.vod_pic
      })
    });
    setResult(d);
  })
}